package com.example.lottery.service.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ActivityPrizeTiersEnum {
    //对于奖品的枚举类
    //只用get方法和构造函数，不用set方法 因为构造函数已经完成了set的工作
    FIRST_PRIZE(1, "一等奖"),

    SECOND_PRIZE(2, "二等奖"),

    THIRD_PRIZE(3, "三等奖");

    private final Integer code;

    private final String message;

    public static ActivityPrizeTiersEnum forName(String name) {
//        ActivityPrizeTiersEnum.values() 返回[FIRST_PRIZE,SECOND_PRIZE,THIRD_PRIZE]之类的
        for (ActivityPrizeTiersEnum activityPrizeTiersEnum : ActivityPrizeTiersEnum.values()) {
            if (activityPrizeTiersEnum.name().equalsIgnoreCase(name)) {
                return activityPrizeTiersEnum;
            }
        }
        return null;
    }
}
